package com.dd.stack.es.service.task;

import com.dd.stack.common.util.annotation.Explanation;
import com.dd.stack.es.mapper.ProductMapper;
import com.dd.stack.es.repository.ProductRepository;
import lombok.Data;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

import java.util.List;


/**
 * @Author liuxianmeng
 * @CreateTime 2024/10/15 0:28
 * @Description 服务器定时任务
 */
@Data
@Slf4j
@Component
@RequiredArgsConstructor
public class ServerTask {
    private final ProductMapper productMapper;
    private final ProductRepository productRepository;

    @Explanation("将MySQL的数据同步到ES")
    @Scheduled(fixedRate = 1000 * 30 * 2)
    public void syncMySQL2ES() {
        //List<ProductESDO> productESDOS = productMapper.selectList(null);
        //for (ProductESDO DO : productESDOS) productRepository.save(DO);
    }
}

